/*
 * @: 插件：获取打包后文件的名称
 * @Version: 1.0
 * @Autor: ziwei
 * @Date: 2022-02-25 16:06:56
 * @LastEditors: ziwei
 * @LastEditTime: 2022-02-25 17:49:26
 */
class AssetsPlugin{
  constructor(options){
    this.options = options
  }
  apply(compiler){
    //https://webpack.docschina.org/api/compiler-hooks/#compilation
    compiler.hooks.compilation.tap('AssetsPlugin',(compilation)=>{
      //https://webpack.docschina.org/api/compilation-hooks/#chunkasset

      //代码块中的资源被添加到complication中会被调用
      //一个代码块会生成一个文件（assrt）文件肯定有文件名filename
      compilation.hooks.chunkAsset.tap('AssetPlugin',(chunk,filename)=>{
        console.log(chunk.name||chunk.id,filename);
      })
    })
  }
}

module.exports = AssetsPlugin